import React, { Component } from 'react';
import {View} from '@tarojs/components';
import {http} from "../../utils/http";
import {
    TARO_ENV,
    RESOURCE_URL,
    APP_SCENIC_NOTICE,
    APP_SCENIC_DETAIL,
    APP_SCENIC_LIST
} from "../../constants/api";

const pageBox = {
    background: "#fff",
    paddingBottom: "20px"
};
const pText = {
	fontSize: "16px",
    lineHeight: "23px",
    padding: "10px 10px 0"
};
const emptyNotice = {
	display: "flex",
    alignItems: "center",
    justifyContent: "center",
    padding: "20% 0",
    fontSize: "16px",
    color: "#666",
};

export default class Notice extends Component {
	constructor(props) {
		super(props);
		this.state = {
			noticeTxt: ""
		};
	}

	componentDidShow() {
        const { location: { params: { uuid } } } = this.props;
        this.getNotice(uuid);
    }

    // get notice
    getNotice = async (uuid) => {
        const res = await http.HGet(APP_SCENIC_NOTICE, {uuid});
        if(res.data) {
            this.setState({ noticeTxt: res.data });
        }
    }

	render() {
		const { noticeTxt } = this.state;

		return (
			<View style={pageBox}>
				{
					noticeTxt ? 
					<View style={pText}>{noticeTxt}</View>
					:
					<View style={emptyNotice}>暂无公告</View>
				}
			</View>
		)
	}
}